//
//  GSYOtherCollectionViewCell.m
//  GoTraveling
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "GSYOtherCollectionViewCell.h"
#import "GSYTableViewCell.h"

@interface GSYOtherCollectionViewCell()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong)UITableView *tableView;


@end


@implementation GSYOtherCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews
{

    self.contentView.backgroundColor = [UIColor redColor];
    
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, self.frame.size.height) style:UITableViewStylePlain];
    
    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerClass:[GSYTableViewCell class] forCellReuseIdentifier:@"cell"];
    
    [self.contentView addSubview:self.tableView];
    



}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return self.otherArray.count;

}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

    return 150;

}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    [self.delegates pushDetailViewController:[[self.otherArray objectAtIndex:indexPath.row]Id]];
    
    
    
    
    
    


}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *cellIdentifier = @"cell";
    
    GSYTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    cell.other = [self.otherArray objectAtIndex:indexPath.row];
    
    CGRect frame = cell.frame;
    
    frame.size.height = 150;
    
    cell.frame = frame;

    return cell;

}

- (void)setOtherArray:(NSMutableArray *)otherArray {
    
    if (_otherArray != otherArray) {
        _otherArray = otherArray ;
    }
//    嵌套刷新写在重写set方法里
    [self.tableView reloadData];
}



@end
